<template>
	<view class="container">
		<view style="width: 100%;height: 20rpx;"></view>
		<view class="list_view">
			<view class="item_view" @click="show = true">
				<view class="left_view">
					授权时间
				</view>
				<view class="right_view">
					<u-icon name="arrow-right" :label="timeLabel" label-pos="left" color="#8A8A8A" size="24"
						label-color="#8A8A8A" label-size="24"></u-icon>
				</view>
			</view>
		</view>
		<view class="bottom_view">
			<view class="again_view" @click="againAction">
				上一步
			</view>
			<view class="next_view" @click="nextAction">
				提交审核
			</view>
		</view>
		<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				show: false,
				list: [{
						value: '1',
						label: '长期'
					},
					{
						value: '2',
						label: '一周'
					},
					{
						value: '3',
						label: '一天'
					},
					// {
					// 	value: '4',
					// 	label: '一次'
					// }
				],
				timeLabel: '请选择',
				timeValue: '',
				deviceType: '',
				deviceNo: '',
				deviceIdList: []
			}
		},
		onLoad() {
			this.deviceIdList = this.$Route.query.deviceIdList
			this.deviceType = this.$Route.query.deviceType
			this.deviceNo = this.$Route.query.deviceNo
		},
		methods: {
			againAction() {
				uni.navigateBack()
			},
			confirm(e) {
				console.log(e);
				this.timeLabel = e[0].label;
				this.timeValue = e[0].value;
			},
			nextAction() {
				if (!this.timeValue) {
					return this.$show.toastMessage("请选择授权时间！");
				}
				this.authorizeApplyCreateData();
			},
			authorizeApplyCreateData() {
				var that = this
				this.$apis.authorizeApplyCreate({
					deviceIdList: this.deviceIdList,
					deviceNo: this.deviceNo,
					deviceType: this.deviceType,
					expireType: this.timeValue
				}).then(result => {
					if (result.res.data.code == '200') {
						this.$show.toastMessage('申请成功！');
						setTimeout(() => {
							// this.$Router.push({
							// 	name: 'applyRecord'
							// })
							uni.switchTab({
								url: '/pages/smartLock/views/index'
							})
						}, 1000)
					} else {
						this.$show.toastMessage(result.res.data.msg);
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		background-color: #F8F8F8;
	}

	.list_view {
		border-top: 1rpx solid #E8E8E8;

		.item_view {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			padding: 15px;
			background-color: #FFFFFF;
			border-bottom: 1rpx solid #E8E8E8;

			.left_view {
				display: flex;
				flex-direction: row;

				.content_view {
					margin-left: 10px;
				}
			}
		}
	}

	.bottom_view {
		width: 100%;
		height: 120rpx;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		background-color: #FFFFFF;

		.again_view {
			width: 40%;
			height: 80rpx;
			color: #324DEC;
			border: 1px solid #324DEC;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 40rpx;
		}

		.next_view {
			width: 50%;
			height: 80rpx;
			background-color: #324DEC;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #FFFFFF;
			border-radius: 40rpx;
		}
	}
</style>